import { Guid } from "guid-typescript";
import { Module } from "./Module";
import { Permission } from "./Permission";
import { MenuLevel } from "./MenuLevel";
import { FileMenuData } from "./menus/FileMenuData";
import { DeviceManagement } from "./menus/DeviceManagement";
import { HomeMenuData } from "./menus/HomeMenuData";
import { BuildingEnergyConsumptionMenuData } from "./menus/BuildingEnergyConsumptionMenuData";
import { SystemManageMenuData } from "./menus/SystemManageMenuData";
import { BasicsMenuData } from "./menus/BasicsMenuData";
/**系统菜单 */
export const MenuData: IMainMenu[] = [
  HomeMenuData,
  FileMenuData,
  DeviceManagement,
  BuildingEnergyConsumptionMenuData,
  SystemManageMenuData,
  BasicsMenuData,
];

export interface IMainMenu {
  /**菜单隶属的模块 */
  module: Module;
  level: MenuLevel;
  /**菜单项 */
  menu: IMainMenuItem;
}

/**菜单项接口 */
export interface IMainMenuItem {
  id: Guid;
  /**菜单名 */
  name: string;

  /**菜单ID（用作文件夹或者文件名） */
  pageId: string;

  /**菜单指向的路径 */
  url?: string;
  /**菜单的层级 */
  leve: Number;

  /**菜单图标（不含 icon 前缀） */
  icon?: string;

  /**支持的权限集合 */
  permissions?: IMenuPermission[];

  /**子菜单 */
  children?: IMainMenuItem[];

  /**是否选中 */
  selected?: boolean;
  /**是否阻止关联的页签关闭 */
  preventTabClose?: boolean;

  /**哈希路径 */
  readonly hash?: string;
}

/**菜单支持的权限接口 */
export interface IMenuPermission {
  /**API 路径 */
  apiPath?: string;
  actionType: Permission;
}
